package oss.ngocminh.fw.forum;

import java.util.ArrayList;
import java.util.List;

import oss.ngocminh.fw.data.Post;

public class RememberCallback implements PostLoadingCallback {

	private int count;
	private List<Post> posts;
	
	@Override
	public void postsLoaded(List<Post> newPosts) {
		if (count == 0) {
			posts = newPosts;
		} else {
			if (count == 1) {
				posts = new ArrayList<Post>(posts);
			}
			posts.addAll(newPosts);
		}
		count++;
	}
	
	public List<Post> getPosts() {
		return posts;
	}

}
